package com.boco.modules.gdtp.controller;

import java.security.Principal;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;





  /** 
   * 平台管理
   * ClassName: PlatformsController <br/>
   * Function: TODO ADD FUNCTION. <br/>
   * Reason: TODO ADD REASON(可选). <br/>
   * date: 2017年3月10日 下午4:42:31 <br/>
   *
   * @author xups
   * @version 
   * @since JDK 1.7+
   */
@Controller
@RequestMapping(value = "/platforms", produces = "application/json;charset=UTF-8")
public class PlatformsController {
	
	/**
	 * 
	 * safetySpecification:(安全规范体系控制中心). <br/>
	 * @date 2017年3月13日
	 * @author xups
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/safetySpecification",method=RequestMethod.GET)
	public String safetySpecification( HttpServletRequest
			request, HttpServletResponse response, Model model){
		model.addAttribute("sysId", 3302);
		model.addAttribute("sysName", "安全规范体系");
		model.addAttribute("userName",getuserName(request));
		return "/platforms/safetySpecification";
	}
	
	
	/**
	 * 
	 * dataCenter:(数据中心跳转). <br/>
	 * @date 2017年3月13日
	 * @author xups
	 * @param request
	 * @param response
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/dataCenter",method=RequestMethod.GET)
	public String dataCenter( HttpServletRequest
			request, HttpServletResponse response, Model model){
		model.addAttribute("sysId", 3303);
		model.addAttribute("sysName", "居民健康信息服务平台-数据中心");
		model.addAttribute("userName",getuserName(request));
		return "/platforms/safetySpecification";
	}
	
	@RequestMapping(value="/platformSystem",method=RequestMethod.GET)
	public String platformSystem( HttpServletRequest
			request, HttpServletResponse response, Model model){
		model.addAttribute("sysId", 3307);
		model.addAttribute("sysName", "基于平台的应用系统");
		model.addAttribute("userName",getuserName(request));
		return "/platforms/safetySpecification";
	}
	
	@RequestMapping(value="/scada",method=RequestMethod.GET)
	public String scada( HttpServletRequest
			request, HttpServletResponse response, Model model){
		model.addAttribute("sysId", 3305);
		model.addAttribute("sysName", "居民健康信息服务平台-数据采集、共享与交换中心");
		model.addAttribute("userName",getuserName(request));
		return "/platforms/safetySpecification";
	}
	
	@RequestMapping(value="/basicService",method=RequestMethod.GET)
	public String basicService( HttpServletRequest
			request, HttpServletResponse response, Model model){
		model.addAttribute("sysId", 3304);
		model.addAttribute("sysName", "居民健康信息服务平台-基础服务");
		model.addAttribute("userName",getuserName(request));
		return "/platforms/safetySpecification";
	}
	
	private String getuserName(HttpServletRequest request) {
		Principal principal = request.getUserPrincipal();
		String sysId=request.getParameter("sysId");
		// 为空赋值为 admin，做测试用
		String userName="";
		if( principal==null){
			userName = "xinjiang01";
		}else{
			userName=principal.getName();
		}
		return userName;
	}
}